home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 23 / AACD 23.iso / AACD / Programming / tek / msg / getmsg.c < prev    next >
C/C++ Source or Header  |  2001-05-18  |  643b  |  38 lines

  1.  
  2. #include "tek/msg.h"
  3. #include "tek/debug.h"
  4. #include "tek/kn/exec.h"
  5.  
  6. /* 
  7. **    TEKlib
  8. **    (C) 2001 TEK neoscientists
  9. **    all rights reserved.
  10. **
  11. **    TAPTR TGetMsg(TPORT *msgport)
  12. **
  13. **    get next pending message from messageport.
  14. **
  15. */
  16.  
  17. TAPTR TGetMsg(TPORT *msgport)
  18. {
  19.     if (msgport)
  20.     {
  21.         TMSG *msg;
  22.         kn_lock(&msgport->lock);
  23.         msg = (TMSG *) TRemHead(&msgport->msglist);
  24.         kn_unlock(&msgport->lock);
  25.         if (msg)
  26.         {
  27.             if (!(msg->status & TMSG_STATUS_PENDING))
  28.             {
  29.                 tdbprintf(2, "*** TEKLIB TGetMsg: getting message with PENDING bit not set\n");
  30.             }
  31.  
  32.             msg->status &= ~TMSG_STATUS_PENDING;
  33.             return (TAPTR) (msg + 1);
  34.         }
  35.     }
  36.     return TNULL;
  37. }
  38.